<div class="admin edit order">

	<h1>Заказ №<?php echo $oRow->id; ?></h1>

	<div class="clear"></div>

	<div class="item">
		<div class="date">Дата заказа: <?php echo date('d.m.Y H:i', strtotime($oRow->date)); ?></div>
	</div>

	<form action="" method="post">
		<?php if($oRow && $oRow->id > 0): ?>
			<input type="hidden" name="id" value="<?php echo $oRow->id; ?>" />
		<?php endif; ?>

		<div class="item">
			<label>Имя</label>
			<input type="text" name="name" value="<?php echo !empty($oRow->name) ? $oRow->name: ''; ?>" />
		</div>
		<div class="item">
			<label>Телефон</label>
			<input type="text" name="phone" value="<?php echo !empty($oRow->phone) ? $oRow->phone: ''; ?>" /> &nbsp;&nbsp;&nbsp; <?php echo !empty($oRow->email) ? '<a target="_blank" href="skype:'.$oRow->phone.'?call">'. $oRow->phone .'</a>': ''; ?>
		</div>
		<div class="item">
			<label>E-mail</label>
			<input type="text" name="email" value="<?php echo !empty($oRow->email) ? $oRow->email: ''; ?>" /> &nbsp;&nbsp;&nbsp; <?php echo !empty($oRow->email) ? '<a target="_blank" href="mailto:'.$oRow->email.'">'. $oRow->email .'</a>': ''; ?>
		</div>

		<div class="item">
			<label>Область</label>
			<input type="text" name="region" value="<?php echo !empty($oRow->region) ? $oRow->region : ''; ?>" />
		</div>
		<div class="item">
			<label>Город</label>
			<input type="text" name="city" value="<?php echo !empty($oRow->city) ? $oRow->city : ''; ?>" />
		</div>
		<div class="item">
			<label>Адрес</label>
			<input type="text" name="address" value="<?php echo !empty($oRow->address) ? $oRow->address : ''; ?>" />
		</div>
		<div class="item">
			<label>Коментарий к заказу</label>
			<input type="text" name="comment" value="<?php echo !empty($oRow->comment) ? $oRow->comment : ''; ?>" />
		</div>

		<div class="item">
			<label>Статус</label>
			<?php foreach(Order::model()->statuses as $status => $title): ?>
				<label class="radio"><input type="radio" <?php echo $oRow->status == $status ? ' checked' : ''; ?> name="status" value="<?php echo $status ?>" /> <span><?php echo $title; ?></span></label>
			<?php endforeach; ?>
		</div>

		<div class="item">
			<label>Текст статуса</label>
			<textarea name="status_text"><?php echo !empty($oRow->status_text) ? $oRow->status_text : ''; ?></textarea>
		</div>

		<div class="item">
			<p>IP: <?php echo !empty($oRow->ip) ? $oRow->ip : '' ?></p>
		</div>

		<?php if(!empty($oGoodsRowset)): ?>
		<div class="goods list">
			<h2>Заказано:</h2>
			<?php foreach($oGoodsRowset as $oGoodsRow):
				if(empty($aOrderGoods[$oGoodsRow->id]))
					continue;
				$aProperties = $aOrderGoods[$oGoodsRow->id]->getProperties();
			?>
			<section>
				<?php if(!empty($oGoodsRow['photo'])): ?>
				<a target="_blank" href="<?php echo $this->createUrl('/goods/default/view/', array('id' => $oGoodsRow->alias, 'category' => $oGoodsRow->category_alias)); ?>"><img alt="" src="<?php echo $this->widget('ext.Img', array('oRow' => $oGoodsRow['photo'], 'size' => 'list')); ?>" /></a>
				<?php endif; ?>
				<a target="_blank" href="<?php echo $this->createUrl('/goods/default/view/', array('id' => $oGoodsRow->alias, 'category' => $oGoodsRow->category_alias)); ?>"><?php echo $aOrderGoods[$oGoodsRow->id]->title; ?></a>
				<a target="_blank" href="<?php echo $oGoodsRow->original_url; ?>">Оригинал</a>
				<p class="price"><?php echo Currencies::convert($aOrderGoods[$oGoodsRow->id]->price); ?></p>
				<div class="info">
					<?php
					foreach($oGoodsRow->property as $pId => $oPropertyRowset):
						foreach($oPropertyRowset as $oProperty):
							if($pId == '3' && !empty($aProperties['size']) && $aProperties['size'] != $oProperty['value_id'])
								continue;
							?>
							<p><span><?php echo $oProperty['title']; ?>:</span>&nbsp;<span><?php echo $oProperty['value']; ?></span></p>
						<?php
						endforeach;
					endforeach;
					?>
					<p><span>Количество:</span>&nbsp;<span><?php echo $aOrderGoods[$oGoodsRow->id]->quantity; ?></span></p>
				</div>

				<?php if(!empty($oGoodsRow->property)): ?>
				<?php endif; ?>
			</section>
			<?php endforeach; ?>
			<div class="clear"></div>
		</div>
		<?php endif; ?>


		<div class="clear"></div>

        <div class="item btn">
            <button type="submit"><span>Зберегти</span></button>
        </div>
    </form>

	<div id="frame"></div>

</div>